package com.probiz.estore.system.service.dwr;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.probiz.estore.common.helper.ConfigUtil;
import com.probiz.estore.core.event.ConfigChangedEvent;
import com.probiz.estore.core.event.EventUtil;
import com.probiz.estore.system.service.SystemConfigManager;
/***
 * 下次不再显示此向导
 * @author Administrator
 *
 */
public class SystemConfigDwr {
	protected final transient Log log = LogFactory.getLog(getClass());
	private SystemConfigManager	systemConfigManager = null;

	public void setSystemConfigManager(SystemConfigManager systemConfigManager) {
		this.systemConfigManager = systemConfigManager;
	}
	
	/**
	 * 勾选和不勾选“下次不再显示此向导”修改数据库相对应的值
	 * @param request
	 * @param response
	 * @return
	 */
	public String toggleShowWizard(HttpServletRequest request, HttpServletResponse response) {
		boolean isShowWizard = ConfigUtil.getInstance().getIsShowWizard();
		if (isShowWizard) {
			this.saveSystemConfig(request,response,"isShowWizard", "false");
		} else {
			this.saveSystemConfig(request,response,"isShowWizard", "true");
		}
		return "true";
	}
	
	
	public String saveSystemConfig(HttpServletRequest request,
			HttpServletResponse response, String configKey, String configVal) {
		systemConfigManager.saveConfigByKey(configKey, configVal);
		EventUtil.getInstance().fire(new ConfigChangedEvent(this));
		return "true";
	}

	

}
